package com.yeung.Tools;

import com.yeung.beans.Department;
import com.yeung.beans.Employee;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class EmployeeConverter implements Converter<String, Employee> {
    @Override
    public Employee convert(String s) {
        Employee employee = null;
        if (s != null) {
            new Employee();
            String[] split = s.split("-");
            employee.setLastName(split[0]);
            employee.setEmail(split[1]);
            employee.setGender(split[2]);
            employee.setDepartment(new Department(split[3]));
        }

        return employee;
    }
}
